﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="moduleManager.aspx.cs" Inherits="manager_systemSetting_moduleManager" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>模块管理</title>
    <!-- select2 -->
    <link href="/reference/plugins/select2/select2.min.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">
    <section class="content-header">
        <h1>模块管理
            <small>系统设置</small>
        </h1>
        <ol class="breadcrumb">
            <li><a><i class="fa fa-dashboard"></i>主页</a></li>
            <li><a href="moduleManager.aspx">系统设置</a></li>
            <li class="active">模块管理</li>
        </ol>
    </section>

    <section class="content">

        <div class="box box-primary">
            <div class="box-header with-border">
                <div>
                    <div class="box-tools pull-left">
                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#moduleManager" data-action="add">添加模块</button>
                    </div>
                </div>
            </div>
            <div class="box-body">
                <table id="moduleManagerList" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th></th>
                            <th class="col-sm-1">名称</th>
                            <th class="col-sm-4">url</th>
                            <th class="col-sm-1">图标</th>
                            <th class="col-sm-1">上级</th>
                            <th>排序</th>
                            <th>可用</th>
                            <th></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <asp:Repeater ID="rptmoduleManager" runat="server">
                            <ItemTemplate>
                                <tr>
                                    <td><a><%# Eval("ID").ToString() %></a></td>
                                    <td><%# Eval("sign").ToString().Trim()=="R"?"<a style='color:red'>":"<a style='color:blue'>&nbsp;&nbsp;>>" %><%# Eval("moduleName").ToString() %></a></td>
                                    <td><a><%# Eval("url").ToString() %></a></td>
                                    <td><a><%# Eval("icon").ToString() %></a></td>
                                    <td><a><%# Eval("parentName").ToString() %></a></td>
                                    <td><a><%# Eval("index").ToString() %></a></td>
                                    <td><%# Eval("isUsing").ToString().Trim()=="True"?"<span style='color:green'>可用</span>":"<span style='color:red'>不可用</span>" %></td>
                                    <td><a data-toggle="modal" data-target="#moduleManager" data-action="update" data-bid="<%# Eval("ID") %>">修改</a></td>
                                    <td><a onclick="deletemoduleManager(<%# Eval("ID") %>)">删除</a></td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tbody>
                </table>
            </div>
            <div style="display: none">
                <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click" />
            </div>

            <div class="modal fade" id="moduleManager" role="dialog" aria-labelledby="moduleManagerLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="moduleManagerLabel"></h4>
                        </div>
                        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <div style="display: none">
                                    <asp:Button ID="btnGet" runat="server" Text="Get" OnClick="btnGet_Click" />
                                </div>
                                <div class="modal-body">
                                    <asp:HiddenField ID="hidBID" runat="server" />
                                    <table class="table table-bordered">
                                        <tr>
                                            <td class="col-sm-2">名称</td>
                                            <td>
                                                <asp:TextBox ID="txtName" CssClass="form-control" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">url</td>
                                            <td>
                                                <asp:TextBox ID="txtUrl" CssClass="form-control" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">icon</td>
                                            <td>
                                                <asp:TextBox ID="txtIcon" CssClass="form-control" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">排序</td>
                                            <td>
                                                <asp:TextBox ID="txtIndex" CssClass="form-control" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">上级</td>
                                            <td>
                                                <asp:DropDownList ID="ddlParent" CssClass="form-control select2" style="width:100%" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">是否可用</td>
                                            <td>
                                                <asp:DropDownList ID="ddlIsUsing" CssClass="form-control" runat="server">
                                                    <asp:ListItem Value="1">是</asp:ListItem>
                                                    <asp:ListItem Value="0">否</asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <asp:Button ID="btnSave" runat="server" Text="确定" CssClass="btn btn-primary" OnClick="btnSave_Click" />
                            <asp:Button ID="btnUpdate" runat="server" Text="修改" CssClass="btn btn-primary" OnClick="btnUpdate_Click" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptPlaceHolder" runat="Server">
    <!-- select2 -->
    <script src="/reference/plugins/select2/select2.full.min.js"></script>
    <script src="/reference/plugins/select2/i18n/zh-CN.js"></script>
    <script type="text/javascript">
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(function () {
            // re-bind your jquery events here   

            $(document).ready(function () {
                $('.select2').select2({
                    language: "zh-CN"
                });
            });
        }
       );
    </script>
    <script>
        $(document).ready(function () {
            $("#moduleManagerList").DataTable(
                {
                    "columnDefs": [
                        { "targets": [0], "visible": false }
                    ],
                    "autoWidth": false,
                    "ordering": false,
                    "language": {
                        "url": "/reference/plugins/datatables/Chinese.json"
                    }
                });

            $('.select2').select2({
                language: "zh-CN"
            });
        });

        $('#moduleManager').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget)

            var action = button.data('action');
            if (action == "add") {
                $("#moduleManagerLabel").text("添加模块");
                $("#ContentPlaceHolder_btnSave").css("display", "");
                $("#ContentPlaceHolder_btnUpdate").css("display", "none");

                $("#ContentPlaceHolder_txtName").val("");
                $("#ContentPlaceHolder_txtUrl").val("");
                $("#ContentPlaceHolder_txtIcon").val("");
                $("#ContentPlaceHolder_txtIndex").val("");
                $("#ContentPlaceHolder_ddlIsUsing").val("1");
                $("#ContentPlaceHolder_ddlParent").val("0");
            }
            else if (action == "update") {
                $("#moduleManagerLabel").text("修改模块");
                $("#ContentPlaceHolder_btnSave").css("display", "none");
                $("#ContentPlaceHolder_btnUpdate").css("display", "");

                var browserID = button.data('bid');
                $("#ContentPlaceHolder_hidBID").val(browserID);
                $("#ContentPlaceHolder_btnGet").click();
            }
        })

        function deletemoduleManager(mlID) {
            var f = confirm("确定要删除此模块吗?");
            if (f == true) {
                $("#ContentPlaceHolder_hidBID").val(mlID);
                $("#ContentPlaceHolder_btnDelete").click();
            }
        }
    </script>
</asp:Content>

